# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - -mtriple=aarch64 -run-pass=legalizer %s | FileCheck %s

# Make sure we don't lose the register bank constraints when
# artifact combining G_UNMERGE_VALUES instructions.
---
name:            test_none_none
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_none_none
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK: $w0 = COPY [[COPY]](s32)
    ; CHECK: $w1 = COPY [[COPY1]](s32)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(s64) = G_MERGE_VALUES %0(s32), %1
    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %2(s64)
    $w0 = COPY %3(s32)
    $w1 = COPY %4(s32)
...
---
name:            test_gpr_none
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_gpr_none
    ; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
    ; CHECK: [[COPY1:%[0-9]+]]:gpr(s32) = COPY $w1
    ; CHECK: $w0 = COPY [[COPY]](s32)
    ; CHECK: $w1 = COPY [[COPY1]](s32)
    %0:gpr(s32) = COPY $w0
    %1:gpr(s32) = COPY $w1
    %2:_(s64) = G_MERGE_VALUES %0(s32), %1
    %3:_(s32), %4:_(s32) = G_UNMERGE_VALUES %2(s64)
    $w0 = COPY %3(s32)
    $w1 = COPY %4(s32)
...
---
name:            test_none_gpr
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_none_gpr
    ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $w1
    ; CHECK: [[COPY2:%[0-9]+]]:gpr(s32) = COPY [[COPY]](s32)
    ; CHECK: [[COPY3:%[0-9]+]]:gpr(s32) = COPY [[COPY1]](s32)
    ; CHECK: $w0 = COPY [[COPY2]](s32)
    ; CHECK: $w1 = COPY [[COPY3]](s32)
    %0:_(s32) = COPY $w0
    %1:_(s32) = COPY $w1
    %2:_(s64) = G_MERGE_VALUES %0(s32), %1
    %3:gpr(s32), %4:gpr(s32) = G_UNMERGE_VALUES %2(s64)
    $w0 = COPY %3(s32)
    $w1 = COPY %4(s32)
...
---
name:            test_fpr_gpr
body:             |
  bb.0.entry:
    ; CHECK-LABEL: name: test_fpr_gpr
    ; CHECK: [[COPY:%[0-9]+]]:fpr(s32) = COPY $w0
    ; CHECK: [[COPY1:%[0-9]+]]:fpr(s32) = COPY $w1
    ; CHECK: [[COPY2:%[0-9]+]]:gpr(s32) = COPY [[COPY]](s32)
    ; CHECK: [[COPY3:%[0-9]+]]:gpr(s32) = COPY [[COPY1]](s32)
    ; CHECK: $w0 = COPY [[COPY2]](s32)
    ; CHECK: $w1 = COPY [[COPY3]](s32)
    %0:fpr(s32) = COPY $w0
    %1:fpr(s32) = COPY $w1
    %2:_(s64) = G_MERGE_VALUES %0(s32), %1
    %3:gpr(s32), %4:gpr(s32) = G_UNMERGE_VALUES %2(s64)
    $w0 = COPY %3(s32)
    $w1 = COPY %4(s32)
...
